package com.example.springaop.brokerdemo1.proxy;

import com.example.springaop.brokerdemo1.subject.HouseSubject;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-12-27
 * Time: 17:41
 */
public class HouseProxy implements HouseSubject {
    //将被代理的对象声明为成员变量
    private HouseSubject houseSubject;

    public HouseProxy(HouseSubject houseSubject) {
        this.houseSubject = houseSubject;
    }

    @Override
    public void rentHouse() {
        System.out.println("我是中介，开始代理");
        houseSubject.rentHouse();
        System.out.println("我是中介，结束代理");
    }

    @Override
    public void saleHouse() {
        //开始代理
        System.out.println("我是中介, 开始代理");
        //代理房东出租房⼦
        houseSubject.saleHouse();
        //代理结束
        System.out.println("我是中介, 代理结束");
    }
}
